<template>
  <div class="baseHole">
    <Page
    :title="title"
    :btnName="btnName"
    :descTitle1="descTitle1"
    :descTitle2="descTitle2"
    :navList="navList"
    :pageData="resData"
    ></Page>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import Page from './page.vue'
export default {
  data () {
    return {
      title: '基坑',
      btnName: '添加',
      descTitle1: '基本信息',
      descTitle2: '传感器列表',
      sceneId: ''
    }
  },
  components: {
    Page
  },
  computed: {
    ...mapState('sceneController', [
      'resData'
    ]),
    navList () {
      let list = []
      list = this.resData.map(item => {
        return { name: item.sceneName }
      })
      return list
    }
  },
  methods: {
    getData () {
      this.getScenList()
    },
    async getScenList () {
      const projectId = localStorage.getItem('projectId')
      const params = {
        projectId,
        sceneTypeId: 1
      }
      this.$store.dispatch('sceneController/updateResData', params).then(res => {
        // console.log(res)
        if (res.data.code === 200 && res.data.data.length) {
          this.$store.commit('sceneController/update_currentList', this.resData[0])
          this.sceneId = this.resData[0].sceneId
          this.getDeviceList()
        }
      })
    },
    getDeviceList () {
      const projectId = localStorage.getItem('projectId')
      const params = {
        projectId,
        index: 1,
        pageSize: 10,
        sceneId: this.sceneId
      }
      this.$store.dispatch('sceneController/updateTableData', params)
    }
  },
  mounted () {
    this.$store.commit('sceneController/update_isAddSensor', false)
    this.getData()
  }
}
</script>

<style lang="scss" scoped>
.baseHole{
  height: 100%;
}
</style>
